package com.mcgrady.oop;

import org.junit.Test;

/**
 * @author McGrady
 */
public class EncapsulationTest {
    static class Cat {
        private String name;
        private Integer age;

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public Integer getAge() {
            return age;
        }

        public void setAge(Integer age) {
            this.age = age;
        }
    }

    /**
     * 被 `static` 修饰时表示共享，唯一，先行。
     * 被 `final` 修饰时表示该属性不可二次赋值属性，建议变量名全大写。
     */
    @Test
    public void classMemberCall() {
        Cat cat01 = new Cat();
        cat01.setName("宝宝");
        System.out.println(cat01.getName());

        Cat cat02 = new Cat();
        System.out.println(cat02.getName());
    }

    static class Dog{
        private static Integer age = 5;

        public static Integer getAge(){
            return age;
        }
    }
    @Test
    public void classStaticMemberCall() {
        System.out.println(Dog.getAge());
    }
}

